package com.atguigu.principle.interfaceSegregationPrinciple;

public class Segregation1 {
    public static void main(String[] args) {
        A a=new A();
        a.depend1(new C());
        a.depend2(new C());
        B b=new B();
        b.depend1(new D());
        b.depend3(new D());
    }
}
interface interface1{
    public void operation1();
}

interface interface2{
    public void operation2();
    public void operation3();

}

interface interface3{
    public void operation4();
    public void operation5();
}


class D implements interface1,interface3{

    @Override
    public void operation1() {
        System.out.println("D实现operation1()");
    }

    @Override
    public void operation4() {
        System.out.println("D实现operation4()");
    }

    @Override
    public void operation5() {
        System.out.println("D实现operation5()");
    }
}

class C implements interface1,interface2{

    @Override
    public void operation1() {
        System.out.println("C实现operation1()");
    }

    @Override
    public void operation2() {
        System.out.println("C实现operation2()");
    }

    @Override
    public void operation3() {
        System.out.println("C实现operation3()");
    }
}
class A{
    public void depend1(interface1 i){
      i.operation1();
    }
    public void depend2(interface2 i){
        i.operation2();
        i.operation3();
    }
}


class B{
    public void depend1(interface1 i){
        i.operation1();
    }
    public void depend3(interface3 i){
        i.operation4();
        i.operation5();
    }

}
